package com.hxh.generater.springBoot.util.methodParse.entity;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @ProjectName: AICode
 * @Package: com.hxh.generater.springBoot.entity
 * @ClassName: JavaClassMethod
 * @Author: HXH
 * @Description: 解析java类中的方法
 * @Date: 2023/12/20 8:43
 */
@Data
public class JavaClassMethod extends MethodBase{
    //public private protect
    private String methodDeclare;
    //返回类型
    private String returnType;
    //参数 类型-> 名称
    private List<JavaClassParams> methodParams;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof JavaClassMethod)) {
            return false;
        }
        JavaClassMethod that = (JavaClassMethod) o;

        List<JavaClassParams> methodParams = this.methodParams;
        List<JavaClassParams> methodParams2 = that.methodParams;
        if (methodParams == null){
            methodParams = new ArrayList<>();
        }
        if (methodParams2 == null){
            methodParams2 = new ArrayList<>();
        }
        if (methodParams.size() != methodParams2.size()){
            return false;
        }
        return getMethodName().equals(that.getMethodName()) &&
                methodParams.containsAll(methodParams2) && methodParams2.containsAll(methodParams);
    }

    @Override
    public int hashCode() {
        return Objects.hash(getMethodName(), getMethodParams());
    }
}
